<?php

namespace TableTennis\TeamBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\AdminBundle\Form\FormMapper;

class TeamAdmin extends Admin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->with('Contenu')
                ->add('media_id', 'sonata_type_model', array('label' => 'Image'), array('edit' => 'list', 'link_parameters' => array('context' => 'team')))
                ->add('name', null, array('label' => 'Nom'))
                ->add('content', null, array('label' => 'Contenu'))
            ->end()
            ->with('Options')
              ->add('num_order', null, array('label' => 'Ordre'))
              ->add('team_category', null, array('label' => 'Catégorie'))
            ->end()
            ->with('Infos générales')
               ->add('creation_user_id', 'sonata_type_model', array('label' => 'Créé par'), array('edit' => 'list'))
               ->add('modification_user_id', 'sonata_type_model', array('label' => 'Modifié par'), array('edit' => 'list'))
            ->end()

        ;
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('name')
            ->add('team_category')
            ->add('num_order')
        ;
    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('name')
            ->add('team_category')
            ->add('num_order')
        ;
    }

    /*public function validate(ErrorElement $errorElement, $object)
    {

    }*/
}

?>